<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='sqjhlb'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">

            <div class="layui-form-item">
                <form name="totalForm" id="totalForm" method="get">

                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;"><fmt:message key='ffbh'/></label>
                        <div class="layui-input-inline">
                            <input type="text" name="shoppingCard.cardNo" value="${params.shoppingCard.cardNo}" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;"><fmt:message key='gwkmc'/></label>
                        <div class="layui-input-inline">
                            <input type="text" name="shoppingCard.name" value="${params.shoppingCard.name}" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;"><fmt:message key='zt'/></label>
                        <div class="layui-input-inline">
                            <select name="activateStatus">
                                <option value="0"><fmt:message key='qxz'/></option>
                                <option value="1" <c:if test="${params.activateStatus == 1}">selected</c:if>><fmt:message key='dsh'/></option>
                                <option value="2" <c:if test="${params.activateStatus == 2}">selected</c:if>><fmt:message key='shtg'/></option>
                                <option value="3" <c:if test="${params.activateStatus == 3}">selected</c:if>><fmt:message key='shbtg'/></option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;"><fmt:message key='sj'/></label>
                        <div class="layui-inline">
                            <input type="text" class="layui-input" style="width: 200px" readonly name="activateTimeStr" id="activateTimeStr" value="${params.activateTimeStr}">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> <fmt:message key='ss'/></button>
                    </div>
                </form>
            </div>
        </div>

    </div>

    <div class="layui-card">
        <div class="layui-field-box layui-form">

            <table class="layui-table" lay-size="sm">
                <thead>
                    <tr>
                        <th><fmt:message key='xh'/></th>
                        <th><fmt:message key='zh'/></th>
                        <th><fmt:message key='ffbh'/></th>
                        <th><fmt:message key='gwkmc'/></th>
                        <th><fmt:message key='yxq'/></th>
                        <th><fmt:message key='mz'/></th>
                        <th><fmt:message key='syje'/></th>
                        <th><fmt:message key='jhhyxq'/></th>
                        <th><fmt:message key='sqsj'/></th>
                        <th><fmt:message key='shzt'/></th>
                        <th><fmt:message key='cz'/></th>
                    </tr>
                </thead>
                <c:forEach items="${page.result}" var="item" varStatus="status">
                    <tr>
                        <td>${status.index + 1}</td>
                        <td>${item.user.username}</td>
                        <td>${item.shoppingCard.cardNo}</td>
                        <td>${item.shoppingCard.name}</td>
                        <td>
                            <c:if test="${item.shoppingCard.validType == 1}">
                                <fmt:formatDate value="${item.shoppingCard.validStartTime}" pattern="yyyy.MM.dd HH:mm"/> -<fmt:formatDate value="${item.shoppingCard.validEndTime}" pattern="yyyy.MM.dd HH:mm"/>
                            </c:if>
                            <c:if test="${item.shoppingCard.validType == 2}"><fmt:message key='lqh'/>${item.shoppingCard.validDays}<fmt:message key='tnksy'/></c:if>
                        <td><fmt:formatNumber value="${item.shoppingCard.faceValue}" type="CURRENCY"/></td>
                        <td><fmt:formatNumber value="${item.balance}" type="CURRENCY"/></td>
                        <td>
                            <c:if test="${item.activateStatus != 2}">-</c:if>
                            <c:if test="${item.activateStatus == 2}"><fmt:formatDate value="${item.activateStart}" pattern="yyyy.MM.dd HH:mm"/> - <fmt:formatDate value="${item.activateEnd}" pattern="yyyy.MM.dd HH:mm"/></c:if>
                        </td>
                        <td><fmt:formatDate value="${item.activateApplyTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                       <td>
                            <c:choose>
                                <c:when test="${item.activateStatus == 1}"><b><fmt:message key='dsh'/></b></c:when>
                                <c:when test="${item.activateStatus == 2}"><b><fmt:message key='shtg'/></b></c:when>
                                <c:when test="${item.activateStatus == 3}"><b><fmt:message key='shbtg'/></b></c:when>
                            </c:choose>
                        </td>
                        <td>
                            <div class="layui-btn-container">
                                <c:choose>
                                    <c:when test="${item.activateStatus == 1}">
                                        <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-danger layui-btn-xs feijin-activate"><fmt:message key='sh'/></a>
                                    </c:when>
                                    <c:otherwise>
                                        <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs feijin-detail"><fmt:message key='ckxq'/></a>
                                    </c:otherwise>
                                </c:choose>
                            </div>
                        </td>
                    </tr>
                </c:forEach>
            </table>
            <jsp:include page="/commons/page.jsp" flush="true"/>
        </div>
    </div>

</div>

<script>

    layui.use(['layer', 'laydate'], function () {
        var laydate = layui.laydate;
        var layer = layui.layer;

        laydate.render({
            elem: "#activateTimeStr",
            type: "date",
            range: true
        });

        /**
         * 审核
         */
        $(".feijin-activate").click(function () {
            var id = $(this).attr("data-id");
            layer.open({
                type: 2,
                title: '<fmt:message key='sh'/>',
                content: '${web_domain}/mall/marketing/shoppingCard/activate/' + id + "/detail",
                maxmin: true,
                area: ['95%', '95%'],
                btn: ['<fmt:message key='qd'/>', '<fmt:message key='fh'/>'],
                yes: function (index, layero) {
                    var submit = layero.find('iframe').contents().find("#submit");
                    submit.click();
                }
            });
        });

        /**
         * 查看详情
         */
        $(".feijin-detail").click(function () {
            var id = $(this).attr("data-id");
            layer.open({
                type: 2,
                title: '<fmt:message key='sqjhxq'/>',
                content: '${web_domain}/mall/marketing/shoppingCard/activate/' + id + "/detail",
                maxmin: true,
                area: ['95%', '95%'],
                btn: ['<fmt:message key='fh'/>']
            });
        });

        /**
         * 发放记录
         */
        $(".feijin-record").click(function () {
            var id = $(this).attr("data-id");
            layer.open({
                type: 2,
                title: '<fmt:message key='ffjl'/>',
                content: '${web_domain}/mall/marketing/shoppingCard/' + id + "/record",
                maxmin: true,
                area: ['95%', '95%'],
                btn: ['<fmt:message key='gb'/>']
            });
        });

    });


    $("#checkboxs").click(function () {
        if (this.checked) {
            $(".feijin-check:checkbox").prop("checked", true);
        } else {
            $(".feijin-check:checkbox").prop("checked", false);
        }
    });

</script>
</body>
</fmt:bundle>
</html>